Scenario #9210: Create Global Admin Subject Without an Own Account

UseCase Create Global Admin Subject Without Account => Global-Admin Subject: hsh-keycloak_sync

Creating accounts needs an acting global-admin USER subject, but that subject does not need to have an own account (and thus a person) itself. Here, such a subject gets created: it is synchronized from Keycloak, and the global ADMIN role is granted to it, but no account is created for it.

Properties

Given

name value
subjectUuid 242a0007-0000-0000-0000-000000000007
subjectName hsh-keycloak_sync

Synchronize the new USER Subject from Keycloak

HTTP PUT "/api/rbac/subjects/242a0007-0000-0000-0000-000000000007" \
  -H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
  `# {` \
  `#   "sub" : "uuid<hsh-alex_superuser>"` \
  `# }` \
  <<EOF
{
  "name" : "hsh-keycloak_sync",
  "type" : "USER"
}
EOF
=> status: 201 CREATED 242a0007-0000-0000-0000-000000000007

This is what the Keycloak sync program does for each new Keycloak user.

Prerequisite: Resolve the UUID of the global ADMIN role

The grant API needs the UUID of the role which we want to grant.

HTTP GET "/api/rbac/roles?name=rbac.global%23global%3AADMIN" \
  -H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
  `# {` \
  `#   "sub" : "uuid<hsh-alex_superuser>"` \
  `# }`
=> status: 200 OK 
[ {
  "uuid" : "2366934b-3ba5-453a-a070-78698db295e0",
  "object.uuid" : "a8842cb7-7284-468a-9e78-07e6fea8bc98",
  "objectTable" : "rbac.global",
  "objectIdName" : "global",
  "roleType" : "ADMIN",
  "roleName" : "rbac.global#a8842cb7-7284-468a-9e78-07e6fea8bc98:ADMIN",
  "roleIdName" : "rbac.global#global:ADMIN"
} ]

Grant the global ADMIN role to the new USER Subject

HTTP POST "/api/rbac/grants" \
  -H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
  `# {` \
  `#   "sub" : "uuid<hsh-alex_superuser>"` \
  `# }` \
  -H 'Hostsharing-Assumed-Roles: rbac.global#global:ADMIN' \
  <<EOF
{
  "assumed" : true,
  "grantedRole.uuid" : "2366934b-3ba5-453a-a070-78698db295e0", // globalAdminRoleUuidToGrant
  "granteeSubject.uuid" : "242a0007-0000-0000-0000-000000000007"
}
EOF
=> status: 201 CREATED 2366934b-3ba5-453a-a070-78698db295e0 // globalAdminRoleUuidToGrant

Verify the new global-admin Subject does not have an own Account

HTTP GET "/api/hs/accounts/current" \
  -H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
  `# {` \
  `#   "sub" : "uuid<hsh-keycloak_sync>"` \
  `# }`
=> status: 200 OK 
{
  "subject" : {
    "uuid" : "242a0007-0000-0000-0000-000000000007",
    "name" : "hsh-keycloak_sync",
    "organization" : "hsh",
    "type" : "USER"
  },
  "person" : null,
  "globalAdmin" : true
}

generated on 2026-08-10 04:34:15 for branch HEAD